<?php

/**
 * This is the model class for table "tbl_jobs_notes".
 *
 * The followings are the available columns in table 'tbl_jobs_notes':
 * @property integer $id
 * @property string $jobid
 * @property string $dateofnote
 * @property string $note
 * @property string $addedby
 * @property string $dateadded
 * @property string $locktime
 * @property string $lockby
 */
class JobsNotes extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return JobsNotes the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'tbl_jobs_notes';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
                        array('jobid,dateofnote,note','required'),
			array('jobid', 'length', 'max'=>36),
			array('addedby', 'length', 'max'=>255),
			array('locktime', 'length', 'max'=>20),
			array('lockby', 'length', 'max'=>30),
			array('dateofnote, note, dateadded', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, jobid, dateofnote, note, addedby, dateadded, locktime, lockby', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'jobid' => 'Jobid',
			'dateofnote' => 'Date Of Note',
			'note' => 'Note',
			'addedby' => 'Added By',
			'dateadded' => 'Dateadded',
			'locktime' => 'Locktime',
			'lockby' => 'Lockby',
		);
	}


	
        public function beforeValidate() {
            $this->addedby=Yii::app()->user->name;
            $this->dateadded=DateUtil::getDefaultCurrentDateTime();
            
            return parent::beforeValidate();
        }
}